<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>


<script type="text/javascript">
    var deleteOpts = {
            msg : "<bean:message key="device.delete.msg" bundle="errors"/>",
            boxTitle : "<bean:message key="device.delete.boxTitle" bundle="errors"/>",
            msgStatus: "<bean:message key="device.delete.msgStatus" bundle="errors"/>"
    };
    var cannotDeleteOpts = {
            msg : "<bean:message key="device.cannot.delete.msg" bundle="errors"/>",
            boxTitle : "<bean:message key="device.cannot.delete.boxTitle" bundle="errors"/>",
            msgStatus: "<bean:message key="device.cannot.delete.msgStatus" bundle="errors"/>"
    };
    var confirmDeleteDeviceOpts = {
    	    msg : "<bean:message key="device.delconfirm.msg" bundle="errors"/>",
    	    boxTitle : "<bean:message key="device.delconfirm.boxTitle" bundle="errors"/>",
    	    msgStatus: "<bean:message key="device.delconfirm.msgStatus" bundle="errors"/>"	
    };
    var changeDeviceAssignedOpts = {
    		msg : "<bean:message key="device.change.user.msg" bundle="errors"/>",
            boxTitle : "<bean:message key="device.change.user.boxTitle" bundle="errors"/>",
            msgStatus: "<bean:message key="device.change.user.msgStatus" bundle="errors"/>"
    };
    var changeDeviceAssignedOfficeOpts = {
    		msg : "<bean:message key="device.change.office.msg" bundle="errors"/>",
            boxTitle : "<bean:message key="device.change.office.boxTitle" bundle="errors"/>",
            msgStatus: "<bean:message key="device.change.office.msgStatus" bundle="errors"/>"
    };
</script>

<c:forEach items="${requestScope.devices}" var="entry">
<div class="result" id="result-${entry.deviceID}">
	<ul class="itemResultNW">
   		<li>
     		<p class="deviceAssignedTo">
     			<select name="assignedTo" class="element select" id="assigned-${entry.deviceID}" onchange="changeDeviceAssigned('${pageContext.request.contextPath}/operator/changedeviceassigned.do', '${entry.deviceID}');">
     				<option value=""><bean:message key="select.option.none"/></option>
				    <c:forEach items="${requestScope.users}" var="item">
				         <option value="${item.userID}" <c:forEach items="${item.device}" var="dev"> <c:if test="${entry.deviceID eq dev.deviceID}">selected="selected"</c:if> </c:forEach>>${item.username}</option>
				    </c:forEach> 
				</select>
     		</p>
        </li>
        <li>
     		<p class="deviceDeviceName">${entry.name}</p>
        </li>
    	<li>
     		<p class="deviceDeviceModel">${entry.model}</p>
        </li>
    	<li>
	     	<p class="deviceVendor">${entry.vendor}</p>
        </li>
        <li>
	     	<p class="deviceReadC"><c:if test="${entry.type eq 'Computer'}"><a href="javascript:showReadingBox('${pageContext.request.contextPath}/operator/loadfeatures.do',${entry.deviceID},'<bean:message key="device.boxtitle.features" bundle="device"/>')"><bean:message key="device.features.read" bundle="device"/></a></c:if></p>
        </li>
        <li>
     		<p class="deviceAssignedOffice">
     			<select name="assignedOffice" class="element select" id="assignedOffice-${entry.deviceID}" onchange="changeDeviceAssignedOffice('${pageContext.request.contextPath}/operator/changedeviceassignedoffice.do', '${entry.deviceID}');">
     				<option value=""><bean:message key="select.option.none"/></option>
				    <c:forEach items="${requestScope.offices}" var="off">
				         <option value="${off.officeID}" <c:forEach items="${off.devices}" var="dev"> <c:if test="${entry.deviceID eq dev.deviceID}">selected="selected"</c:if> </c:forEach>>${off.number}</option>
				    </c:forEach> 
				</select>
     		</p>
        </li>
        <li class="panelOperatorDevice" id="panelOperatorDevice-${entry.deviceID}">
        	<p class="OperatorDeviceDelete">
			 <a class="aOperatorFaqDelete" href="javascript:deleteDevice(${entry.deviceID},'${pageContext.request.contextPath}/operator/deletedevice.do');">
			     <img class="imgPanelOperatorFaq" src="<c:url value="/layout/images/form/Delete.png"/>" alt="Delete" title="Delete" />
			 </a>
			</p>
			<p class="OperatorDeviceEdit"><a class="aOperatorFaqEdit" href="${pageContext.request.contextPath}/operator/activeeditdevice.do?deviceID=${entry.deviceID}"><img class="imgPanelOperatorFaq" src="<c:url value="/layout/images/form/Edit2.png"/>" alt="Edit" title="Edit" /></a></p>
		</li>			            
	</ul>
</div>
</c:forEach>